<?php
/* @var $this SiteController */
Yii::import('ext.jquery-gmap.*');
$this->pageTitle=Yii::app()->name;
?>

<div class="span-6 " >
    <?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'localiza',
        'enableAjaxValidation'=>false,
    )); ?>
    <p>
        <label for="listaEquipos">Equipo</label><br>
        <?php 

            echo CHtml::activeDropDownList($model,'equipo_id', 
                  $model->comboEquipos(),
                  array(
                      'empty' => 'Seleccionar...',
                      'style'=>'width: auto;',
                      'ajax' => array(
                            'type'=>'POST', 
                            'url'=>$this->createUrl('site/refreshEquipo'),
                            'data'=>array('equipo_id'=>'js:this.value'),
                            'update'=>'#detalleEquipo',
                      ),
                  ));
        ?>
    </p>
    <p>
        <?php echo CHtml::activeTextArea($model, 'detalle', 
                array(
                    'cols'=>'28',
                    'rows'=>'5',
                    'id'=>'detalleEquipo'
                ));
        ?>
    </p>
    <p style="text-align: center">
        <?php
        echo CHtml::submitButton('Actualizar punto');
        ?>
    </p>
    <?php $this->endWidget(); ?>  
</div>
<div class="span-17 last ">
    <div class="span-17 last">
        <?php
        $gmap = new EGmap3Widget();
        $gmap->setSize(669, 400);
        
        
        $options = array();
        if($ultima_loc != null) 
        {
            $options = array(
                'scaleControl' => true,
                'streetViewControl' => FALSE,
                'zoom' => 14,
                'center' => array($ultima_loc->latitud, $ultima_loc->longitud),
                'mapTypeId' => EGmap3MapTypeId::ROADMAP,
                'mapTypeControlOptions' => array(
                        'style' => EGmap3MapTypeControlStyle::DROPDOWN_MENU,
                        'position' => EGmap3ControlPosition::TOP_CENTER,
                ),
                'zoomControlOptions' => array(
                        'style' => EGmap3ZoomControlStyle::SMALL,
                        'position' => EGmap3ControlPosition::BOTTOM_CENTER
                ),
            );
            $markerOptions = new EGmap3MarkerOptions();
            $markerOptions->title = GPSHelper::etiquetaEquipo($ultima_loc->equipo_id, $ultima_loc->hora);
            $markerOptions->icon = $ultima_loc->imagen;

            $marker = new EGmap3Marker();
            $marker->latLng = array($ultima_loc->latitud, $ultima_loc->longitud);
            $marker->setOptions($markerOptions);
            $gmap->add($marker);
        } else {
            $options = array(
                'scaleControl' => true,
                'streetViewControl' => FALSE,
                'zoom' => 6,
                'center' => array(19.414792, -99.100113),
                'mapTypeId' => EGmap3MapTypeId::ROADMAP,
                'mapTypeControlOptions' => array(
                        'style' => EGmap3MapTypeControlStyle::DROPDOWN_MENU,
                        'position' => EGmap3ControlPosition::TOP_CENTER,
                ),
                'zoomControlOptions' => array(
                        'style' => EGmap3ZoomControlStyle::SMALL,
                        'position' => EGmap3ControlPosition::BOTTOM_CENTER
                ),
            );
        }
        
        $gmap->setOptions($options);
        $gmap->renderMap();
        
        ?>
    </div>
    <div class="span-17 last">
        <!-- foo -->
    </div>
</div>
